{
  "properties" : { },
  "id" : "ab3158d777424e058f778fb75ce090fc",
  "script" : null,
  "groupId" : "a01229049ea4496dab1bf8538af48dca",
  "name" : "测试定时任务",
  "createTime" : null,
  "updateTime" : 1741367987163,
  "lock" : null,
  "createBy" : null,
  "updateBy" : null,
  "path" : "tets",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ {
    "name" : "require_login",
    "value" : "false",
    "description" : "该接口需要登录才允许访问",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"message\": \"success\",\n    \"data\": null,\n    \"timestamp\": 1741359727832,\n    \"executeTime\": 41\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import log
import cn.hutool.core.date.DateUtil;

let order_re = db.table("orders").where().eq("id",21).selectOne()
let productSnapshot = order_re.productSnapshot::json
let productSnapshotConfig = productSnapshot.config::json

 log.info("order_re--->"+order_re)
  log.info("productSnapshot--->"+productSnapshot)
  log.info("productSnapshotConfig--->"+productSnapshotConfig)

let currentTime = DateUtil.now();
log.info("currentTime"+currentTime)


 let now = DateUtil.date();
 log.info("now--->"+now)


// log.info(" productSnapshot.days-->"+ productSnapshot.days)
//订阅表增加订阅记录
db.table("subscription").insert({
    userId: order_re.userId,
    packageId: productSnapshot.id,
    startTime: currentTime,
    endTime: DateUtil.format(DateUtil.offsetDay(DateUtil.date(), productSnapshotConfig.days), "yyyy-MM-dd HH:mm:ss"),
    createBy: order_re.userId,
    createDate: currentTime,
})
